<?php

/**
 * 
 * @author littlexiang<littlexiang521@gmail.com>
 * @version $Id: UserModel.php 62 2009-07-22 04:45:58Z littlexiang521 $
 */
class UserModel extends Model {
    protected $_table = 'user';
    
    public function userLogin ($info) {
        $ret = $this->retrive('username = ?', array(
            $info['username']));
        
        if ($ret->password === md5($info['password'])) {
            return $ret;
        } else {
            return false;
        }
    
    }
    
    public function checkUserExist ($username) {
        return $this->retrive('username = ?', array(
            $username)) ? true : false;
    
    }
    
    public function addUser ($info) {
        
        $info['password'] = md5($info['password']);
        $info['create_time'] = time();
        $info['email'] = 'test@test.com';
        $info['is_deleted'] = 0;
        
        return $this->insert($info);
    }
}
?>